module("BattleResult", package.seeall)

function create()
	local self = ccs.GUIReader:getInstance():widgetFromJsonFile("res/UI/BattleUI/BattleResult.ExportJson")

	init(self)

	return self
end

function init( self )
	local panelMain = self:getChildByName("Panel_Main")
	local buttonExit = panelMain:getChildByName("Button_Exit")
	local buttonReplay = panelMain:getChildByName("Button_Replay")

	local imageLight = panelMain:getChildByName("Image_Light")

	local actionRotate = cc.RotateBy:create(6,360)
	imageLight:runAction(cc.RepeatForever:create(actionRotate))

	buttonExit:addTouchEventListener(
		function ( sender, eventType )
			if (eventType == ccui.TouchEventType.ended) then
				SceneManager.switchToScene(HomeScene.create())
			end
		end)

	buttonReplay:addTouchEventListener(
		function ( sender, eventType )
			if (eventType == ccui.TouchEventType.ended) then
				SceneManager.switchToScene(MapScene.create())
			end
		end)

	self:setSize(cc.Director:getInstance():getWinSize())
end